package com.stork.cms.activity;



import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;import com.stork.cms.R;
import com.stork.cms.fragment.ForgetPasswordFragment;
import com.stork.cms.fragment.LoginPageFragment;
import com.stork.cms.utilities.SharedPreference;

public class Login extends Activity {
	
	public static final String COLLEGE_NAME = "collegename";
	public static final String ADDRESS = "address";
	public static final String PHONE= "phone";
	public static final String EMAIL= "email";
	public static final String WEBSITE= "website";
	
	ActionBar ab;	
	TextView LoginTextview,ForgetPasswordTextview;
	Fragment ForgetpasswordFragment,LoginFragment;
	String name="Stork Software Systems Pvt Lmt",
			cadd="No 45,Pondy bazar",
			cphone="9894564152",
			cemail="hr@storksystem.com",
			cwebsite="click GoTo www.storksystems.com";	 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_homelogin);
		
		ab=getActionBar();
//		ab.setDisplayHomeAsUpEnabled(true);
		ab.setTitle("Login");
		
		LoginTextview=(TextView)findViewById(R.id.logintextView1);
		ForgetPasswordTextview=(TextView)findViewById(R.id.forgetpasswordtextView2);
		
				
		SharedPreference.writeString(getApplicationContext(), COLLEGE_NAME, name);
		SharedPreference.writeString(getApplicationContext(), ADDRESS, cadd);
		SharedPreference.writeString(getApplicationContext(), PHONE, cphone);
		SharedPreference.writeString(getApplicationContext(), EMAIL, cemail);
		SharedPreference.writeString(getApplicationContext(), WEBSITE, cwebsite);
		
		LoginFragment=new LoginPageFragment();
		FragmentManager fm=getFragmentManager();
		FragmentTransaction ft=fm.beginTransaction().replace(R.id.fragment, LoginFragment);
		ft.commit();
		LoginTextview.isEnabled();
		LoginTextview.setBackgroundResource(R.color.none);
		ForgetPasswordTextview.setTextColor(Color.BLACK);
		ForgetPasswordTextview.setBackgroundResource(R.color.white);
		LoginTextview.setTextColor(Color.WHITE);
		
		
		ForgetPasswordTextview.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				ForgetpasswordFragment=new ForgetPasswordFragment();
				FragmentManager fm=getFragmentManager();
				FragmentTransaction ft=fm.beginTransaction().replace(R.id.fragment, ForgetpasswordFragment);
				ft.commit();
				ab.setTitle("Forget Password");	
				LoginTextview.setTextColor(Color.BLACK);
				LoginTextview.setBackgroundResource(R.color.white);
				ForgetPasswordTextview.setBackgroundResource(R.color.none);
				ForgetPasswordTextview.setTextColor(Color.WHITE);
				
			}		
		});
		
LoginTextview.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				LoginFragment=new LoginPageFragment();
				FragmentManager fm=getFragmentManager();
				FragmentTransaction ft=fm.beginTransaction().replace(R.id.fragment, LoginFragment);
				ft.commit();
				LoginTextview.setBackgroundResource(R.color.none);
				ForgetPasswordTextview.setTextColor(Color.BLACK);
				ForgetPasswordTextview.setBackgroundResource(R.color.white);
				LoginTextview.setTextColor(Color.WHITE);
								
			}		
		});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		
		switch (item.getItemId()) 
		{
		case android.R.id.home:
			Intent rlogin=new Intent(Login.this, Login.class);
			startActivity(rlogin);
			return true;

		default:
			break;
		}
		return super.onOptionsItemSelected(item);
	}
	

}
